<link rel="import" href="/components/polymer/polymer.html">
<link rel="import" href="/components/core-ajax/core-ajax.html">

<polymer-element name="ajax-service" extends="core-ajax">
    <script>
        Polymer('ajax-service', {
            ready: function () {
                this.headers = get_meta_csrf_token();
                this.super();
            }
        });
        function get_meta_csrf_token() {
            var metas = document.getElementsByTagName("meta");
            for (var counter = 0; counter < metas.length; counter++) {
                if (metas[counter].getAttribute("name") == "csrf-token") {
                    return '{"X-CSRF-Token":"' + metas[counter].content + '"}';
                }
            }
            return '';
        }
    </script>
</polymer-element>
